export const createRenderer = (opts = {}) => {
  function unmount(container) {
    container.innerHTML = ""
  }
  function mountElement(vnode, container) {
    const element = opts.createElement(vnode.tag)
    if (
      typeof vnode.children == 'string'
    ) {
      opts.setText(element, vnode.children)
    }
    opts.appendChild(container, element)
  }

  function render(vnode, container) {
    if (!vnode) {
      unmount()
    } else {
      mountElement(vnode, container)
    }
  }
  return {
    render
  }
}
